<%@ page import="com.lovebridge.model.User" %>
<%@ page import="java.util.List" %>
<%@ page import="com.lovebridge.SystemManager" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" errorPage="/error.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.extremecomponents.org" prefix="ec"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
    String userEmail=request.getParameter("userEmail");
    List<User> users;
    if (userEmail!=null) {
        users = SystemManager.getPersist().readList(User.class,"select * from user where email like ?","%"+userEmail+"%");
    } else {
        users = SystemManager.getPersist().readList(User.class,"select * from user");
    }
    request.setAttribute("userList",users);
%>
<jsp:include page="/header.jsp" flush="false"/>
<c:if test="${!empty succMessage}">
    <b><font color="blue"><c:url value="${succMessage}"/>
    </font> </b>
</c:if>
<c:if test="${!empty errorMessage}">
    <b><font color="red"><c:url value="${errorMessage}"/>
    </font> </b>
</c:if>
<div class="content_d">
    <form id="userController" name="userController"
          action="<c:url value="users.jsp"/>" method="post">
        <table>
            <tr>
                <td>
                    Email:
                </td>
                <td>
                    <input type="text" name="userEmail" id="userEmail" value="${userEmail}" size="30"/>
                </td>
                <td>
                    <input type="hidden" name="action" id="action" value="search"/>
                    <input type="submit" value="搜索" class="btn s"/>
                </td>
            </tr>
        </table>
    </form>
    <ec:table filterable="false" sortable="true" items="userList"
              var="user" action="users.jsp"
              rowsDisplayed="15"
              imagePath="images/table/*.gif">
        <ec:row>
            <ec:column property="userName"><a href="editUser.jsp?id=${user.id}">${user.userName}</a></ec:column>
            <ec:column property="email"></ec:column>
            <ec:column property="role"></ec:column>
            <ec:column property="createTime"></ec:column>
            <ec:column property="updateTime"></ec:column>
        </ec:row>
    </ec:table>
</div>
<div class="clear"></div>
<jsp:include page="/footer.jsp" flush="false"/>
